﻿#include<opencv2/opencv.hpp>
#include<iostream>
#include<vector>
using namespace cv;
//-------------------------------------------------------------
//void on_Trackbar(int, void*);
//const int trackMaxH = 160;
//const int trackMaxS = 255;
//const int trackMaxV = 255;
//int HofTrack=160;
//int SofTrack;
//int VofTrack;
//#define WINDOW_NAME "HSV窗口"
//cv::Mat srcImag;
//cv::Mat dstImag;
//std::vector<cv::Mat> channels;
//cv::Mat H, S, V;
//-------------------------------------------------------------
int main()
{
	//初始化Mat方法
	/*cv::Mat Imag(240,320,CV_8UC3);
	cv::Mat Imag2(Size(240, 320), CV_8UC3);
	cv::Mat Imag3(240, 320, CV_8UC3, Scalar(255, 0, 0));
	cv::imshow("test", Imag);
	cv::imshow("testColor", Imag3);*/
	//-------------------------------------------------------------
	//图像读取和显示
	cv::Mat testImag;
	testImag = cv::imread("1.png");
	/*cv::namedWindow("示例输出窗口");
	cv::imshow("示例输出窗口",testImag);*/
	//-------------------------------------------------------------
	//图像存储演示
	/*cv::Mat grayImag;
	cv::cvtColor(testImag, grayImag, CV_BGR2GRAY);
	cv::imshow("灰度输出窗口", grayImag);
	cv::imshow("BGR输出窗口", testImag);*/
	//-------------------------------------------------------------
	//Mat类型深浅复制演示
	/*cv::Mat copyImag;
	testImag.copyTo(copyImag);
	cv::Mat cloneImag = testImag.clone();
	cv::Mat shallowImag(testImag);
	cv::imshow("原始输出窗口", testImag);
	cv::imshow("copyTo输出窗口", copyImag);
	cv::imshow("clone输出窗口", cloneImag);
	cv::imshow("构造函数输出窗口", testImag);
	cv::GaussianBlur(testImag, testImag, Size(15, 15), 1);
	cv::circle(testImag, cv::Point(150, 150), 50, cv::Scalar(0, 0, 255), 3);
	cv::imshow("原始输出窗口", testImag);
	cv::imshow("copyTo输出窗口", copyImag);
	cv::imshow("clone输出窗口", cloneImag);
	cv::imshow("构造函数输出窗口", testImag);*/
	//--------------------------------------------------------------
	//色彩空间示例
	/*srcImag = cv::imread("HSV.png");
	cv::cvtColor(srcImag, srcImag, CV_BGR2HSV);
	cv::namedWindow(WINDOW_NAME);
	cv::createTrackbar("H_high", WINDOW_NAME, &HofTrack, trackMaxH, on_Trackbar);
	on_Trackbar(HofTrack, 0);*/
	cv::waitKey(0);
	
}

//void on_Trackbar(int, void*)
//{
//	cv::split(srcImag, channels);
//	H = channels.at(0);
//	S = channels.at(1);
//	V = channels.at(2);
//	cv::threshold(H, H, HofTrack, 180, THRESH_TOZERO);
//	cv::threshold(H, H, HofTrack + 20, 180, THRESH_TOZERO_INV);
//	//cv::threshold(S, S, 43, 255, THRESH_TOZERO);
//	//cv::threshold(V, V, 46, 255, THRESH_TOZERO);
//	
//	cv::merge(channels, dstImag);
//	cv::cvtColor(dstImag, dstImag, CV_HSV2BGR);
//	cv::imshow(WINDOW_NAME, dstImag);
//}
